package com.example.ioc.controller;

import com.example.ioc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Li_yizYa
 * Date: 2025/7/7
 * Time: 21:24
 */
@Controller
public class UserController {
    // 属性注入
//    @Autowired
//    private UserService userService;

    // 构造方法注入
//    private UserService userService;
//    public UserController() {
//        System.out.println("无参构造方法");
//    }
//    @Autowired
//    public UserController(UserService userService) {
//        System.out.println("有参构造方法");
//        this.userService = userService;
//    }

    // setter 方法注入
    private UserService userService;

    @Autowired
    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    public void say() {
        System.out.println("UserController say...");
        userService.say();
    }

}
